{extend name="main"}

{block name="content"}

<div style="max-width:1000px">
    <form class="layui-card layui-form">
        <div class="layui-card-body think-box-shadow">
            <div class="layui-form-item margin-bottom-0">
                <label class="layui-form-label">Storage<br><span class="nowrap color-desc">存储类型</span></label>
                <div class="layui-input-block">
                    {foreach ['local'=>'本地服务器存储','qiniu'=>'七牛云对象存储','oss'=>'阿里云OSS存储'] as $k=>$v}
                    <input type="radio" data-storagetype="{$k}" name="storage_type" value="{$k}" title="{$v}" lay-filter="storage_type">
                    {/foreach}
                    <p class="help-block">请选择文件存储类型，其它云储存需要配置正确的参数才可以上传文件哦！</p>
                </div>
            </div>
        </div>
    </form>
    <div class="padding-top-15 padding-bottom-10 think-box-shadow">
        <div class="layui-anim layui-anim-upbit" data-type="oss">{include file='config/file_oss'}</div>
        <div class="layui-anim layui-anim-upbit" data-type="local">{include file='config/file_local'}</div>
        <div class="layui-anim layui-anim-upbit" data-type="qiniu">{include file='config/file_qiniu'}</div>
    </div>
</div>

{/block}

{block name="script"}
<script>
    $(function () {
        apply('{:sysconf("storage_type")}');
        window.form.render();
        window.form.on('radio(storage_type)', function (data) {
            apply(data.value);
        });

        function apply(value) {
            this.$active = $("[data-storagetype='" + value + "']").trigger('click');
            if (this.$active.size() < 1) $("[data-storagetype]:first").trigger('click');
            $('[data-type="' + value + '"]').show().siblings('[data-type]').hide();
        }
    });
</script>
{/block}